package com.jf.blog.controller;

import com.jf.blog.form.LoginForm;
import com.jf.blog.form.vip.VipRegisterForm;
import com.jf.blog.service.UserinfoService;
import com.jf.blog.util.ResultJson;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "登录模块")
public class LoginController {
    @Autowired
    private UserinfoService userinfoService;

    @PostMapping("/login")
    @ApiOperation("用户登录")
    public ResultJson login(@RequestBody LoginForm loginForm) {
        return userinfoService.login(loginForm);
    }

    @PostMapping("/register")
    @ApiOperation("会员注册")
    public ResultJson register(@RequestBody VipRegisterForm form) {
        userinfoService.vipRegister(form);
        return ResultJson.success();
    }
}
